<?php

namespace app\admin\validate;

use app\common\enums\StatusEnum;
use think\Validate;

class User extends Validate
{
    protected $rule = [
        // 用户名 为字母和数字，下划线_及破折号-，user表（不包含前缀）中唯一
        'user_name|账号' => 'require|alphaDash|length:3,20|unique:user',
        'password|密码' => 'require|length:6,16',
        'rePassword|确认密码' => 'require|confirm:password',
        'mobile|手机号码' => 'mobile',
        'status' => 'in:' . StatusEnum::DISABLED . ',' . StatusEnum::ENABLED,
    ];

    // edit 验证场景定义
    public function sceneEdit()
    {
        return $this->remove('password', 'require')
            ->remove('rePassword', 'require');
    }
}